<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <!-- <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" /> -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/backstage/css/font.css">
    <link rel="stylesheet" href="/backstage/css/xadmin.css">
    <style>

      li{
        float:left;
        margin:20px;
      }

      img{
        width:150px;
      }

      #folder_list p{
        margin-top:-15px;
      }

      #folder_list div{
        text-align: center;
      }
      #folder_list input{
        display: block;
        text-align:center;
      }

      #folder_list button{
        margin-top:10px;
        display: none;
      }
    </style>
  </head>
  
  <body >
  {eq name='sel' value=''}
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">附件管理</a>
        <a>
          <cite>图片管理</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
  {/eq}
    <div class="x-body" id='role'>
      {eq name='sel' value=''}
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
          <input class="layui-input" placeholder="开始日" name="start" id="start" >
          <input class="layui-input" placeholder="截止日" name="end" id="end" >
          <input type="text" name="seach_text"  placeholder="输入图片名称搜索" id='seach_text' class="layui-input" >
          <button class="layui-btn"  lay-submit="" lay-filter="sreach" type="button" @click="seachData"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      {/eq}
      <div>
        <button class="layui-btn layui-btn-danger" onclick="deleteFolder()"><i class="layui-icon"></i>选中删除</button>          
        <button class="layui-btn" onclick="x_admin_show('新建文件夹','{:config(\'template.root_path\')}/resource/create_folder/{$folder_type}',500,200)"><i class="layui-icon"></i>新建文件夹</button>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
          <i class="layui-icon" style="line-height:30px">ဂ</i></a>
      </div>
      <hr>
     <div id='folder_list'>
       <ul>
         <li v-for="(item,index) in folderList">
          <div style='display:inline' class="layui-unselect layui-form-checkbox" onclick="checkThis(this)" lay-skin="primary" :data-id='item.id'><i class="layui-icon">&#xe605;</i></div>            
           <div>
              <a :href='"image_list?folder_id="+item.id+"&sel={$sel}"'><img src="/backstage/images/folder.jpg"></a>
              <p onclick='showUpdateFolder(this)'>{{item.folder_name}}</p>
              <input id='folder_name' :folder_id='item.id'  type="text" :value="item.folder_name" onBlur="checkFolderName(this)" autofocus="autofocus" style='display:none'>
              <button class="layui-btn layui-btn-xs  layui-btn-danger" :folder_id='item.id' onclick="deleteFolder(this)"><i class="layui-icon ">&#xe640;</i>删除文件夹</button>
      
           </div>
         </li>
       </ul>
     </div>

    </div>

    <!-- import iView -->
  
  </body>
  <script type="text/javascript" src="/js/jquery.js"></script>
  <script type="text/javascript" src="/js/vue.js"></script>
  <!-- <script src="http://unpkg.com/iview/dist/iview.min.js"></script>     -->
  <script type="text/javascript" src="/backstage/js/xadmin.js"></script>
  <script type="text/javascript" src="/backstage/lib/layui/layui.js" ></script>
  
  <script>

    var app = new Vue({
      el:'#role',
      data: {
        folderList:[],
      },
      methods:{
        //获取列表
        getListData: function () {


          var that = this;
          $.get('{:config("template.root_path")}/resource/folder_list',{'folder_type':'{$folder_type}'},function(res){
            if(res.code==200){
              that.folderList = res.data;
            }else{
              layer.msg(res.msg,{icon:5,time:1000});
            }

//            // 获得frame索引
//            var index = parent.layer.getFrameIndex(window.name);
//            //关闭当前frame
//            parent.layer.close(index);

          },'json');
        },




        //删除
        image_delete:function(index,id){
          var that = this;
          layer.confirm('删除后不可恢复',{title:'谨慎操作！'},function(index){
            $.post('{:config(\'template.root_path\')}/resource/image_delete',{id:id},function(msg){
            if(msg.code==200){
              layer.msg('已删除!',{icon:1,time:1000});
              that.getListData();
            }else{
              layer.msg(res.msg,{icon:5,time:1000});
            }
          },'json')
         });
        },


        //搜索
        seachData:function(){
          this.pageData.end = $('#end').val();
          this.pageData.start = $('#start').val();
          this.pageData.seach_text = $('#seach_text').val();
          this.getListData();
          this.page();
        }
      },
      created: function () {



        this.getListData();
      }
    });

   layDate();

  </script>
</html>